package com.zhuiYun.project.api.order.controller;


import com.zhuiYun.project.annotation.OptLog;
import com.zhuiYun.project.api.order.service.orderService;
import com.zhuiYun.project.common.response.CommonConstants;
import com.zhuiYun.project.common.response.CommonResult;
import com.zhuiYun.project.util.pageUtil.PageRequest;
import com.zhuiYun.project.util.pageUtil.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.persistence.Id;
@Slf4j
@CrossOrigin
@RestController
@Api(tags = "订单管理")
@RequestMapping("/orderlist")
public class orderController {
    @Autowired
    orderService orderservice;

     @GetMapping("orderList")
     @ApiOperation(value = " 订单管理的查询方法")
     @OptLog(modular = "订单管理", type = CommonConstants.ADD, describe = "查询订单")
     CommonResult orderList(String orderNumber, Integer userId, PageRequest pageResult){
        PageResult pageResult1 =orderservice.orderList(orderNumber,userId,pageResult);
        return CommonResult.ok(pageResult1);
    }


    /**
     * @Author 小江
     * @Description //TODO 订单发货
     * @Date 15:01 2023/4/18
     **/
    @DeleteMapping("dischargedOrder")
    @ApiOperation(value = "订单发货")
    @OptLog(modular = "订单发货", type = CommonConstants.ADD, describe = "通过发货方法")
    CommonResult dischargedOrder(Integer id){
        int i = orderservice.dischargedOrder(id);
        log.info("删除diy商品");
        if (i > 0) {
            return CommonResult.ok();
        } else {
            return CommonResult.error();
        }
    }


}
